home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 31
/
Aminet 31 (1999)(Schatztruhe)[!][Jun 1999].iso
/
Aminet
/
dev
/
gui
/
gui4cli.lha
/
Gui4Cli
/
Docs
/
Tutorials
/
IfTest.gc
< prev
next >
Wrap
Text File
|
1999-04-21
|
2KB
|
111 lines
G4C
; This is a convoluted function, to show you how if/elseif/while etc
; constructs work with the new additions. The gui loads up, goes
; through the stuf below, prints out the result, and quits.
; it should print out :
; ** CORRECT 1 2 3 4 5 test finished
xonload
if 1 = 5
or 1 = 2
or 1 = 9
say 'wrong.1\n'
elseif 1 = 2
or 2 = 3
say 'wrong.2\n'
else
ifexists dos ram
OrifExists dos dh0
and 1 = 0
say 'wrong.3\n'
elseif 1 != 0
a = 1
while $a < 5
and 1 = 1
gosub iftest.gc one ; this is the correct one
endwhile
elseif 2 = 2
or 3 = 3
say 'wrong.4\n' ; although this is also correct, the
else ; previous elseif has precedence
say 'wrong.5\n'
endif
if 2 = 2
and 3 = 4
say 'wrong.6\n'
endif
endif
if 5 = 6
or 6 = 7
or 7 = 9
say 'wrong.end\n'
elseifexists dos nodrive
and 1 = 1
say 'wrong.end2\n'
else
say 'test finished.\n' ; this should also be printed.
endif
guiquit iftest.gc
; --------------------- routine testing
xroutine one
if 1 = 2
or 2 = 3
say 'wrong r1.1\n'
elseif 3 = 3
and 4 = 4
if 5 = 5
and 6 = 6
gosub iftest.gc two ; this is correct
elseif 7 = 9
or 9 = 9
or 1 = 1
say 'wrong r1.2\n' ; also correct, but should NOT be executed
else
say 'wrong r1.3\n'
endif
else
say 'wrong r1.4\n'
endif
xroutine two
if 1 = 2
or 2 = 3
say 'wrong r2.1\n'
elseif 3 = 3
and 4 = 4
if 5 = 5
or 7 = 6
if $a = 1
say '\n ** CORRECT! 1 ' ; Yes!
while $a < 5
or 1 = 2
counter a inc 1
say '$a '
endwhile
endif
elseif 9 = 9
and 1 = 1
say 'wrong r2.2\n'
else
say 'wrong r2.3\n'
endif
else
if 2 = 2
or 1 = 1
say 'wrong r2.4\n'
endif
endif